var server = require('../../util/server.js');

Page({
    data: {
        indicatorDots: true,
        vertical: false,
        autoplay: false,
        interval: 3000,
        duration: 1200,
        place_name: '',
        place_addr: '',
        place_people: '',
        place_devices: '',
        place_images: '',
        place_detail: '',
        place_id: 1,
        place_price: 1,
    },
    onReady: function () {
        this.getDetail(this.data.place_id);
    },
    onLoad: function(options) {  
        this.setData({
            place_id: options.placeId
        })
    },
    getDetail: function (id) {
        var self = this;
        server.resource('place/' + id).then(function(res){
            self.setDetail(res);
        });
    },
    setDetail: function (res) {
        if (res == '') {
            return;
        }
        var obj = res;
        var place = obj.data.data;
        this.setData({
            place_name: place.name,
            place_addr: place.address,
            place_people: place.galleryful,
            place_devices: place.device,
            place_images: place.img,
            place_detail: place.detail,
            place_price: place.price,
        })
    },
    requestPlace: function (e) {
        
    }
})